 //获取token
 var token = sessionStorage.getItem('token');
 function personInfo() {
     var headers = {
         'Content-Type': "application/json",
         'Authorization': token
     };
     $.ajax({
         url: "http://lex.itdida.com/itdida-api/person/info",
         type: "post",
         headers: headers,
         data: '',
         dataType: 'json',
         success: function (data) {
             $("#emailText").text(data.data.email);
             $("#telText").text(data.data.mobile);
             $("#nameText").text(data.data.name);
             console.log(data);
         },
         error: function (data) {
         }
     })
 }
 personInfo();
 $(".disable").click(function () {
     layer.msg('功能开发中，敬请期待', {
         anim: 0
     });
 })
 $("#all_left .Huifold .item").click(function () {
     $(this).addClass("active").siblings().removeClass('active');
     $(this).parent().siblings().children().removeClass('active');
     $(this).parent().siblings().children().children().children().removeClass('active');
     $(this).parent().parent().parent().siblings().children().removeClass('active');
 });
 function time() {
     var that = $(".get_code2")
     var timeo = 60;
     var timeStop = setInterval(function () {
         timeo--;
         if (timeo > 0) {
             that.text('重新获取(' + timeo + 's)');
             that.attr('disabled', 'disabled');//禁止点击
         } else {
             timeo = 60;//当减到0时赋值为60
             that.text('获取验证码');
             clearInterval(timeStop);//清除定时器
             that.removeAttr('disabled');//移除属性，可点击
         }
     }, 1000)
 }
 $('#mpanel4').slideVerify({
     type: 2,		//类型
     vOffset: 5,	//误差量，根据需求自行调整
     vSpace: 5,	//间隔
     imgName: ['1.jpg', '2.jpg'],
     imgSize: {
         width: '400px',
         height: '200px',
     },
     blockSize: {
         width: '40px',
         height: '40px',
     },
     barSize: {
         width: '400px',
         height: '40px',
     },
     ready: function () {
     },
     success: function () {
         $("#verify").css("display", "none");
         time();
         //......后续操作
     },
     error: function () {
         //alert('验证失败！');
     }
 });
 var phone;
 var phoneRule = /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-7|9])|(?:5[0-3|5-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1|8|9]))\d{8}$/;
 $(".get_code2").click(function () {
     phone = $("#phone").val();
     if (!(phoneRule.test(phone))) {
         layer.msg('手机号码格式不正确',);
     } else {
         $("#verify").show();
     }
 })
 var verifyCode = new GVerify("v_container");
 $(".update_Email").click(function () {
     layer.open({
         type: 1,
         title: ['修改登陆邮箱', 'font-size:16px;color:#000;'],
         closeBtn: 1,
         area: ['439px', '303px'],
         shadeClose: true,
         btn: ['提交修改并发送邮件'],
         btnAlign: 'c',
         skin: 'send_email',
         content: $('#verify1'),
         yes: function (index, layero) {
             var exampleInputEmail = $("#exampleInputEmail1").val();
             var exampleInputPassword = $("#exampleInputPassword1").val();
             var exampleInputEmail1 = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
             var exampleInputPasswordRule = /^[a-zA-Z0-9]{8,15}$/;
             var res = verifyCode.validate(document.getElementById("code_input").value);
             if (!(exampleInputPasswordRule.test(exampleInputPassword))) {
                 layer.msg('密码为8-15个字符',);
                 console.log(!(exampleInputPasswordRule.test(exampleInputPassword)))
             }
             else if (!(exampleInputEmail1.test(exampleInputEmail))) {
                 layer.msg('邮箱格式不正确',);
             }
             else if (!(res)) {
                 layer.msg('验证码错误',);
             }
             else {
                 layer.close(index);
                 $("#emailText").html(exampleInputEmail);
             }
         },
     });
 });
 $(".update_number").click(function () {
     layer.open({
         type: 1,
         title: ['修改手机号', 'font-size:16px;color:#000;'],
         closeBtn: 1,
         area: ['440px', '331px'],
         shadeClose: true,
         btn: ['保存'],
         btnAlign: 'c',
         skin: 'update_number_two',
         content: $('#verify2'),
         yes: function (index, layero) {
             var phoneOld = $("#phoneOld").val();

             var phoneCode = $("#phoneCode").val();
             var phoneCodeRule = /^[0-9]{4}$/
             if (!(phoneRule.test(phoneOld))) {
                 layer.msg('手机号码格式不正确',);
             }
             else if (!(phoneRule.test(phone))) {
                 layer.msg('手机号码格式不正确',);
             }
             else if (!(phoneCodeRule.test(phoneCode))) {
                 layer.msg('验证码错误',);
             }
             else {
                 layer.close(index);
                 $("#telText").html(phone);
             }
         },
     });
 })
 $(".add_name").click(function () {
     layer.open({
         type: 1,
         title: ['添加真实姓名', 'font-size:16px;color:#000;'],
         closeBtn: 1,
         area: ['440px', '195px'],
         shadeClose: true,
         btn: ['保存'],
         btnAlign: 'c',
         skin: 'add_name_two',
         content: $('#verify3'),
         yes: function (index, layero) {
             var newName = $("#newName").val();

             var newNameRule = /^((?:[\u4e00-\u9fa5·]{2,16})$)|(^[a-zA-Z]{1}[a-zA-Z\s]{0,20}[a-zA-Z]{1}$)/
             if (!(newNameRule.test(newName))) {
                 layer.msg('请输入真实姓名',);
             } else {
                 layer.close(index);
                 $("#telText").html(phone);
             }
         },
     });
 })
 $(".update_area").click(function () {
     layer.open({
         type: 1,
         title: ['修改所在地区', 'font-size:16px;color:#000;'],
         closeBtn: 1,
         area: ['440px', '195px'],
         shadeClose: true,
         skin: 'region',
         btn: ['保存'],
         btnAlign: 'c',
         content: $('#verify4'),
         yes: function (index, layero) {
             var changeCountryInput = $("#select2-changeCountryInput-container").text();
             $("#Country").html(changeCountryInput);
             layer.close(index);
         },
     });
 })
 $(".add_gender").click(function () {
     layer.open({
         type: 1,
         title: ['添加性别', 'font-size:16px;color:#000;'],
         closeBtn: 1,
         area: ['290px', '185px'],
         shadeClose: true,
         skin: 'add_gender_two',
         btn: ['保存'],
         btnAlign: 'c',
         content: $('#verify5'),
         yes: function (index, layero) {
             var changeSexInput = $(':radio[name="sex"]:checked').val();
             $("#sex").html(changeSexInput);
             layer.close(index);
         },
     });
 })
 layui.use('laydate', function () {
     var laydate = layui.laydate;
     //执行一个laydate实例
     laydate.render({
         elem: '#changeBirthdayInput', //指定元素
         position: 'fixed'
     });
 });
 $(".add_birthday").click(function () {
     layer.open({
         type: 1,
         title: ['添加生日', 'font-size:16px;color:#000;'],
         closeBtn: 1,
         area: ['440px', '200px'],
         shadeClose: true,
         skin: 'add_birthday_two',
         btn: ['保存'],
         btnAlign: 'c',
         content: $('#verify6'),
         yes: function (index, layero) {
             var changeBirthdayInput = $('#changeBirthdayInput').val();
             $("#birthday").html(changeBirthdayInput);
             layer.close(index);
         },
     });
 });
 $(".add_IDcard").click(function () {
     layer.open({
         type: 1,
         title: ['添加证件', 'font-size:16px;color:#000;'],
         closeBtn: 1,
         area: ['440px', '250px'],
         shadeClose: true,
         skin: 'add_IDcard_two',
         btn: ['保存'],
         btnAlign: 'c',
         content: $('#verify7'),
         yes: function (index, layero) {
             var newIDCard = $("#newIDCard").val();
             var newIDCardType = $(".newIDCardType").val();
             var IDCardRule = /(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/;
             var passportRule = /^[EeKkGgDdSsPpHh]\d{8}$/;
             var PassRule = /(^[a-zA-Z][0-9]{9}$)|(^(([Ee][a-fA-F])|([DdSsPp][Ee])|([Kk][Jj])|([Mm][Aa])|(1[45]))\d{7}$)/;
             switch (newIDCardType) {
                 case "身份证":
                     if (!(IDCardRule.test(newIDCard))) {
                         layer.msg('身份证号码格式不正确',);
                     } else {
                         $("#idCardText").html(newIDCard);
                         layer.close(index);
                     }
                     break;
                 case "护照":
                     if (!(passportRule.test(newIDCard))) {
                         layer.msg('护照号码格式不正确',);
                     } else {
                         $("#idCardText").html(newIDCard);
                         layer.close(index);
                     }
                     break;
                 case "港澳台居民来往大陆/内地通行证":
                     if (!(PassRule.test(newIDCard))) {
                         layer.msg('通行证号码格式不正确',);
                     } else {
                         $("#idCardText").html(newIDCard);
                         layer.close(index);
                     }
                     break;
             }
         },
     });
 })
 function readURL(input) {
     if (input.files && input.files[0]) {
         var reader = new FileReader();
         reader.onload = function (e) {
             $('#blah').attr('src', e.target.result);
         }
         reader.readAsDataURL(input.files[0]);
     }
 }
 $("#imgInp").change(function () {
     readURL(this);
 });
 function readURL2(input) {
     if (input.files && input.files[0]) {
         var reader = new FileReader();
         reader.onload = function (e) {
             $('#blah2').attr('src', e.target.result);
         }
         reader.readAsDataURL(input.files[0]);
     }
 }
 $("#imgInp2").change(function () {
     readURL2(this);
 });
 //下拉框搜索
 $(function () {
     $(".select2").select2();
 });